New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tsafe

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsafe

A collection of utilities to step up your TypeScript game

  • 1.8.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
96K
decreased by-7%
Maintainers
1
Weekly downloads
 
Created

What is tsafe?

The tsafe package provides utility functions for TypeScript that help ensure type safety and improve type inference. It includes functions for exhaustive type checks, type assertions, and more.

What are tsafe's main functionalities?

exhaustiveSwitch

The exhaustiveSwitch function is used to ensure that all possible cases in a switch statement are handled. If a case is not handled, it throws an error, helping developers catch missing cases at compile time.

function exhaustiveSwitch(value: never): never { throw new Error(`Unhandled case: ${value}`); }

assert

The assert function is used to assert that a condition is true. If the condition is false, it throws an error. This is useful for runtime checks that also inform TypeScript's type system.

function assert(condition: any, msg?: string): asserts condition { if (!condition) { throw new Error(msg); } }

Other packages similar to tsafe

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc